fix: handle missing session_id when Cursor runs claude-code hooks#1306
Open
Zubairu wants to merge 1 commit intothedotmack:mainfrom
Open
fix: handle missing session_id when Cursor runs claude-code hooks#1306Zubairu wants to merge 1 commit intothedotmack:mainfrom
Zubairu wants to merge 1 commit intothedotmack:mainfrom
Conversation
When Cursor IDE runs claude-code hooks in compatibility mode, it sends conversation_id instead of session_id. This caused the UserPromptSubmit hook to call /api/sessions/init with an empty contentSessionId, resulting in a 400 error and blocking prompt submission with: "Submission blocked by hook: Session initialization failed: 400" Fix: - Accept conversation_id as fallback when session_id is not present - Skip gracefully (return success) when neither ID is available This allows claude-mem to work correctly when Cursor's agent runs Claude Code-compatible hooks without providing a session_id. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When Cursor IDE runs Claude Code-compatible hooks, it sends
conversation_idinstead ofsession_idin the hook input. TheUserPromptSubmithook (new-hook.ts) readssession_iddirectly, so it becomesundefined, and the subsequent call to/api/sessions/initfails with HTTP 400 becausecontentSessionIdis required.This causes Cursor to show a blocking error dialog:
The error happens every time a user submits a prompt in Cursor's built-in agent when claude-mem hooks are active.
Root Cause
new-hook.tsinterface and destructuring only readssession_id:Cursor provides
conversation_id, notsession_id, socontentSessionIdsent to the worker isundefined→ 400.Fix
Two-part fix:
conversation_idas fallback whensession_idis absentTesting
Reproduced by using Cursor's built-in agent with claude-mem hooks active. After this fix, Cursor submits prompts without the blocking error.
🤖 Generated with Claude Code